<?php
date_default_timezone_set('Australia/Sydney');
//error_reporting(E_ALL ^ E_NOTICE);
require_once($_SERVER["DOCUMENT_ROOT"]."/utils.php");
require_once $_SERVER["DOCUMENT_ROOT"]."/Swift-4.1.6/lib/swift_required.php";

if(isset($_POST['email'])) {
	// Create the Transport
	$transport = Swift_SmtpTransport::newInstance('smtp.hosting.bulletproof.net', 25);
	// Create the Mailer using your created Transport
	$mailer = Swift_Mailer::newInstance($transport);
	
	// body
	$body = file_get_contents(hostname()."/EDM/event/email-demo.html");
	$body = str_replace("images/", hostname()."/EDM/event/images/", $body);
	
	// Create a message
	$message = Swift_Message::newInstance('Google Maps Business Demonstration')
		->setFrom(array('no-reply@discovermapsforbusiness.com' => 'no-reply@discovermapsforbusiness.com'))
		->setTo(array($_POST['email'] => $_POST['email']))
		->setBody($body)
		->setContentType('text/html')
	;

	// send the message
	if (!$mailer->send($message, $failures))
	{
		echo "Failures";
		print_r($failures);
	}
	else {
		echo "Success";
	}
}
?>